/-app
/-docs ...
/-docs/types ...
/-docs/types/text ...
/-docs/types/text/css
/-docs/types/text/html
/-docs/types/text/js
/-docs/types/text/json
/-docs/types/text/less
/-docs/types/text/sass
/-docs/types/text/scrollerView
/-docs/types/text/scss
CodeMirror-ext.css
CodeMirrorDocHandler.ts
api.ts
load.ts
api.ts
listSubmodules.ts
load.ts
DocHost.ts
/-files
/-imports
/-persistence
/-typings
codemirror.addons.d.ts
codemirror.d.ts
knockout.d.ts
websql.d.ts
zip.d.ts
errors.js
functions.ts
index.html
try.js
94
​
95
    }
96
​
97
    hideEditor(): void {
98
​
99
      this._saveTimer.endWaiting();
100
      
101
      this.textDoc.editor.off('changes', this._closures.cm_changes);
102
      this.textDoc.editor.off('cursorActivity', this._closures.cm_cursorActivity);
103
      this.textDoc.editor.off('viewportChange', this._closures.cm_viewportChange);
104
​
105
      if (this.textDoc.close)
106
        this.textDoc.close();
107
      
108
      var editor = this.textDoc.editor;
109
      this.textDoc.editor = null;
110
      
111
      var cmPool =
112
        CodeMirrorDocHandler.codeMirrorEditorPools[this.moduleName || ''];
113
      
114
      cmPool.push(editor);
115
    }
116
    
117
    remove() {
118
      this._saveTimer.stop();
119
      this.textDoc.remove();
120
      this.textDoc.doc = null;
121
    }
122
​
123
    private _docChanges(docChanges: CodeMirror.EditorChange[]) {
124
​
125
      if (this.textDoc.onChanges)
126
        this.textDoc.onChanges(docChanges);
127
​
128
      if (this._scrollerModel)
129
        this._scrollerModel.docChanges(docChanges);
130
​
131
      this._saveTimer.interval = (this.moduleObj && this.moduleObj.saveDelay) || saveDelay;
132
      this._saveTimer.reset();
133
​
134
      if (docChanges.length) {
135
        var latestChange = docChanges[docChanges.length - 1];
136
        if (latestChange.text && latestChange.text.length) {
137
          var latestChangeText = latestChange.text[latestChange.text.length - 1];
138
​
139
          var triggers = this.moduleObj && this.moduleObj.completionTriggers ?
140
            this.moduleObj.completionTriggers :
141
            completionTriggers;
142
​
143
          if (ko.utils.arrayIndexOf(triggers, latestChangeText.charAt(latestChangeText.length - 1)) >= 0) {
144
            this._triggerCompletion();
145
          }
146
        }
147
      }
148
    }
149
    
150
    private _triggerCompletion() {
151
      if (this.textDoc.onCompletion) {
152
        var asyncContinueCompletion = (cm, callback, options) => this._continueCompletion(callback);
153
        (<any>asyncContinueCompletion).async = true;
154
        this.textDoc.editor.showHint({
155
          hint: asyncContinueCompletion,
156
          completeSingle: false
157
        });
158
​
159
      }
160
    }
161
    
162
    private _continueCompletion(callback: (result: CodeMirror.showHint.CompletionResult) => void) {
163
      this.textDoc.onCompletion(callback);
164
    }
165
​
166
    private _cursorActivity() {
167
      if (this.textDoc.onCursorMoved) {
168
        var cursorPos = this.textDoc.doc.getCursor();
169
        this.textDoc.onCursorMoved(cursorPos);
170
      }
171
​
172
      // TODO: scroller/thickBar cursor activity
173
​
174
    }
175
    
176
    private _viewportChange(from: number, to: number) {
177
      if (this.textDoc.onViewportMoved) {
178
        this.textDoc.onViewportMoved(from, to);
179
      }
180
​
181
      if (this._scrollerModel)
182
        this._scrollerModel.viewportMoved(from, to);
183
      
184
    }
185
​
186
    private _save() {
187
      this.storage.write(this.textDoc.doc.getValue());
188
    }
153:36